package com.example.skycode7.servlet;

import com.example.skycode7.bean.NewsBean;
import com.example.skycode7.dao.NewsDao;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/newsdatail.html")
public class NewsDetailServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws SecurityException, IOException {
        String NewsID = req.getParameter("NewsID");
        int id = Integer.parseInt(NewsID);
        NewsBean news = (new NewsDao()).getOne(id);
        req.setAttribute("title", news.getNewsTitle());
        req.setAttribute("content", news.getNewsContent());
        req.getRequestDispatcher("/newsFrontDetail.jsp").forward(req, resp);
    }
}

